import { createContext, useReducer } from 'react'

import summary from '../markdown/summary.md'

export const MyContext = createContext()

const reducer = (state, action) => {
    switch (action.type) {
        case 'get': return state
        case 'set': {
            state = action.value
            return state
        }
        default: return 'err'
    }
}

export const MyReducer = props => {

    const [data, dispatch] = useReducer(reducer, summary)

    return (
        <MyContext.Provider value={{ data, dispatch }}>
            {props.children}
        </MyContext.Provider>
    )
}
